/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author longdm0708l
 */
@Stateless
public class WarehouseFacade implements WarehouseFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Warehouse warehouse) {
        em.persist(warehouse);
    }

    public void edit(Warehouse warehouse) {
        em.merge(warehouse);
    }

    public void remove(Warehouse warehouse) {
        em.remove(em.merge(warehouse));
    }

    public Warehouse find(Object id) {
        return em.find(Warehouse.class, id);
    }

    public List<Warehouse> findAll() {
        return em.createQuery("select object(o) from Warehouse as o").getResultList();
    }

}
